package com.woniuxy.lab.woniu_lab.mqListener;


import com.woniuxy.lab.woniu_lab.model.Log;
import com.woniuxy.lab.woniu_lab.service.LogService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author chenweiji
 */
@Component
@Slf4j
@RocketMQMessageListener(topic = "greatLog-topic", consumerGroup = "lab-log")
public class CreateLog implements RocketMQListener<Log> {
    @Resource
    private LogService LogService;



    /**
     * 消费消息(记录订单日志)
     */
    @Override
    public void onMessage(Log log1) {
        log.info("记录日志:{}", log1);
        LogService.save(log1);
        log.info("记录日志完成");
    }
}
